﻿using IterationLife.Datas;
using IterationLife.Educations.Models;
using IterationLife.Educations.Queries;
using IterationLife.Educations.Repositories;
using IterationLife.PlatformBackEnd.AppServices.Contracts.Educations;
using IterationLife.PlatformBackEnd.AppServices.Dtos.Educations;
using Util.Applications;
using Util.Datas.Queries;

namespace IterationLife.PlatformBackEnd.AppServices.Impl.Educations {
    /// <summary>
    /// 科目能力服务
    /// </summary>
    public class SubjectAbilityService : ApplicationServiceBase<SubjectAbility, SubjectAbilityDto, SubjectAbilityQuery>, ISubjectAbilityService {
        /// <summary>
        /// 初始化科目能力服务
        /// </summary>
        /// <param name="unitOfWork">工作单元</param>
        /// <param name="subjectAbilityRepository">科目能力仓储</param>
        public SubjectAbilityService( IApplicationUnitOfWork unitOfWork, ISubjectAbilityRepository subjectAbilityRepository )
            : base( unitOfWork, subjectAbilityRepository ) {
            SubjectAbilityRepository = subjectAbilityRepository;
        }
        
        /// <summary>
        /// 科目能力仓储
        /// </summary>
        protected ISubjectAbilityRepository SubjectAbilityRepository { get; set; }
        
        /// <summary>
        /// 转换为数据传输对象
        /// </summary>
        /// <param name="entity">实体</param>
        protected override SubjectAbilityDto ToDto( SubjectAbility entity ) {
            return entity.ToDto();
        }

        /// <summary>
        /// 转换为实体
        /// </summary>
        /// <param name="dto">数据传输对象</param>
        protected override SubjectAbility ToEntity( SubjectAbilityDto dto ) {
            return dto.ToEntity();
        }
        
        /// <summary>
        /// 创建查询对象
        /// </summary>
        /// <param name="param">科目能力查询实体</param>
        protected override IQueryBase<SubjectAbility> CreateQuery( SubjectAbilityQuery param ) {
            return new Query<SubjectAbility>( param );
        }
    }
}